package com.example.springmvcwork.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttribute;



@Controller
public class sessionController {
    @GetMapping(value = "/acc")
    @ResponseBody
    public String acc(HttpSession session, @SessionAttribute(name = "data",required = false)String data, int  para)
    {
        if(data==null ){
            data="0";
            session.setAttribute("data","0");
        }
        int sum=Integer.valueOf(data)+para;
        session.setAttribute("data",sum);
        return "para is:"+sum;
    }
    @GetMapping(value = "/demo")
    public String demo(){
        return "demo";
    }
}
